<template>
	<view class="drawCards u-skeleton">
		<u-navbar title="店长" :background="{
			'backgroundColor':'#fff'
		}" :borderBottom="false" class="u-skeleton-rect"></u-navbar>
		<div class="box-scroll">
			<diy-scorll  :Empty='goodsList.length ? false : true' :status = 'status' @scrolltolower='getgoods' @refresherrefresh='refresherrefresh' 
			:is_display = 'goodsList.length'>
				<view class="item" @click="$util.redirectTo('/pages/my/transfer',item)" v-for="(item,index) in goodsList" :key="index">
					<view class="left">
						<image :src="$util.img(item.image)" mode="heightFix"></image>
						<view class="content">
							<view class="title">{{item.name}}</view>
							<view class="num">库存：{{item.no_use}}</view>
						</view>
					</view>
					<view class="right">转赠</view>
				</view>
			</diy-scorll>
		</div>
		<u-skeleton :loading="loding" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>
<script>
	export default {
		data(){
			return {
				// 首次进入加载
				loding: true,
				//列表数据
				goodsList:[],
				//控制下方显示字样
				status:'loadmore',
				//书记请求参数
				page:{
					page:1,
					page_size:8,
				}
			}
		},
		onShow() {
			this.refresherrefresh();
		},
		methods:{
			// 下拉双薪
			refresherrefresh(callback){
				this.page = {
					page:1,
					page_size:8,
				},
				this.getgoods(callback);
			},
			getgoods(callback){
				this.$http.asyncSendrequest({
					url:'/profile/storeCard',
					data:{
						...this.page
					},
					success:res=>{
						if(res.code == '0') {
							if(this.page.page == 1) this.goodsList = [];
							if(res.data.length){
								this.goodsList = this.goodsList.concat(res.data);
								this.page.page += 1;
							} else {
								//下面加载的文字
								this.status = 'nomore'
							}
							if(typeof callback == 'function') callback();
							this.loding = false;
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.drawCards{
		min-height: 100vh;
		.box-scroll{
			height: calc(100% - 160rpx);
			margin-top: 30rpx;
			.item{
				margin: 0 30rpx 30rpx;
				background: #fff;
				border-radius: 6rpx;
				min-height: 150rpx;
				padding: 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.left{
					display: flex;
					align-items: center;
					image{
						height: 140rpx;
						margin-right: 20rpx;
					}
					.content{
						display: flex;
						justify-content: space-between;
						flex-direction: column;
						height: 140rpx;
						.title{
							font-size: 28rpx;
						}
						.num{
							color: rgba(0,0,0,.4);
						}
						
					}
				}
				.right{
					padding: 10rpx 30rpx;
					height: 60rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 28rpx;
					border: 1rpx solid rgba(0,0,0,.4);
					border-radius: 60rpx;
				}
			}
		}
		
	}
</style>